<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>用户登录</title>
		<script
			src="http://sta.ganjistatic1.com/public/js/util/ganji/ganji.__1353566951__.js"
			type="text/javascript"></script>
		<link href="css/login.css" rel="stylesheet" type="text/css" />
	</head>

	<body data-gjch="/user/login">
		<!--header s-->
		<jsp:include page="include/head.jsp" flush="true"></jsp:include>
		<!--header e-->
		<!-- logo s -->
		<div class="w top-search">
			<h1 class="logo">
				<a target="_self" href="/"><img width="155" height="62"
						src="css/image/logo.png">
				</a>
			</h1>
		</div>
		<!-- logo e -->
		<div id="wrapper" class="clearfix">
			<div class="login-div clearfix">
				<!--reg-box start-->
				<div class="reg-box">
					<p class="userreg">
						还没有账号？10秒马上注册
					</p>
					<form action="/user/register.php" method="post" id="registerform">
						<div class="error-box"></div>

						<div class="reg-field">
							<label for="username">
								用户名：
							</label>
							<input value="" name="username" type="text" class="input-text" />
							<input type="hidden" value="http://xm.ganji.com/wu/" name="next">
							<input type="hidden" value="" name="second">
						</div>
						<div class="error-box">
							<span id="tip_username"></span>
						</div>

						<div class="reg-field">
							<label for="password">
								密码：
							</label>
							<input value="" name="password" type="password"
								class="input-text" />
						</div>
						<div class="error-box">
							<span id="tip_password"></span>
						</div>

						<div class="reg-field">
							<label for="confirm-password">
								确认密码：
							</label>
							<input value="" name="password2" type="password"
								class="input-text" />
						</div>
						<div class="error-box">
							<span id="tip_password2"></span>
						</div>

						<div class="reg-field checkcode-reg">
							<label for="yzm">
								验证码：
							</label>
							<input value="" name="checkcode" type="text" maxlength="4"
								class="input-text" id="checkcode_input" />
							<script>
                function resetCheckcode() {
                    var img = document.getElementById('img_checkcode');
                    if (img!=null) {
                        img.src = '/common/checkcode.php?nocache=' + (new Date() * 1);
                    }
                    var ccode   = document.getElementById('checkcode_input');
                    ccode.value = '';
                    ccode.focus();
                    return false;
                }
                </script>
							<label style="width: 130px">
								<img id="img_checkcode"
									src="/common/checkcode.php?nocache=1363404760"
									align="absmiddle" />
							</label>
						</div>
						<div class="error-box" id="tip_checkcode">
							<span></span>
						</div>
						<div class="radio">
							<font style="display: inline;">请输入上方字符，不区分大小写</font><a href="#"
								onClick="resetCheckcode();return false;">看不清？换个验证码</a>
						</div>

						<div class="reg-radio">
							<span class="reg-protocol"> <input type="checkbox"
									name="affirm" checked="" class="radio-btn" autocomplete="off">
								<label for="term-of-service">
									我接受二手交易网
									<a target="_blank"
										href="http://www.ganji.com/misc/abouts/index.php?act=termofservice">服务条款</a>
								</label> </span>
						</div>
						<div class="error-box" id="reg-error">
							<span id="tip_affirm"></span>
						</div>

						<div class="reg-submit" id="reg-submit">
							<input type="submit" value="立即注册" id="reg_submit" class="reg-btn">
						</div>
						<div style="display: none" class="reg-submit" id="reg-msg">
							<span class="fc-submit">正在提交···</span>
						</div>

						<input type="hidden" name="next" value="http://xm.ganji.com/wu/" />
						<input type="hidden" name="second" value="" />
					</form>
				</div>
				<!--reg-box end-->
				<!--login-box start-->
				<div class="login-box">
					<p class="userlogin">
						用户登录
					</p>
					<form id="loginform" action="loggingin" method="post">

						<div id="login_msg_error" class="error-box">
							<span class="validatorMsg validatorError"></span>
						</div>

						<div class="field">
							<label for="username">
								账号：
							</label>
							<input value="" name="login_username" type="text"
								class="input-text" title="用户名/邮箱/手机号" />
						</div>
						<div id="login_tip_error" class="error-box">
							<span></span>
						</div>

						<div class="field">
							<label for="password">
								密码：
							</label>
							<input value="" name="login_password" type="password"
								class="input-text" maxlength="16" />
						</div>
						<div id="login_tip_password" class="error-box">
							<span></span>
						</div>

						<!--验证码begin-->
						<div class="field checkcode" id="checkcode" style="display: none">
							<label for="username">
								验证码：
							</label>
							<input value="" name="login_checkcode" type="text" maxlength="4"
								class="input-text" id="login_checkcode_input" />
							<label style="width: auto">
								<img id="login_img_checkcode" align="absmiddle" />
							</label>
							<a id="reset_code" href="#">看不清？换个验证码</a>
							<div id="login_tip_checkcode" class="error-box">
								<span></span>
							</div>
						</div>
						<!--验证码end-->

						<div class="radio">
							<input value="14" checked name="setcookie" type="checkbox"
								class="radio-btn" />
							<label for="stay-login">
								下次自动登录(公共场所请勿勾选)
							</label>
							<div class="forget-pw">
								<a class="forget-pw" target="_blank"
									href="/user/get_password.php">忘记密码?</a>
							</div>
						</div>

						<div id="login-submit" class="login-submit"
							style="display: block;">
							<input class="search-btn" type="submit" value="登录交易网">
						</div>
						<div id="login-msg" class="reg-submit" style="display: none;">
							<span class="fc-submit">正在提交···</span>
						</div>
					</form>

					<div class="other-login">
						<p class="login-tips">
							使用合作网站账号登录：
						</p>
						<p class="login-type clearfix">
							<a class="qq"
								href="http://www.ganji.com/user/thirdparty/qq_login.php?next=http%3A%2F%2Fxm.ganji.com%2Fwu%2F"
								title="" target="_blank">qq登录</a>
							<a class="sina"
								href="http://www.ganji.com/user/thirdparty/sina_login.php?next=http%3A%2F%2Fxm.ganji.com%2Fwu%2F"
								title="" target="_blank">新浪微博</a>
							<!-- <a class="taobao" href="#" title="" target="_blank">淘宝网</a>-->
							<a class="txweibo"
								href="http://www.ganji.com/user/thirdparty/qqweibo_login.php?next=http%3A%2F%2Fxm.ganji.com%2Fwu%2F"
								title="" target="_blank">腾讯微博</a>
							<a class="feixin"
								href="http://www.ganji.com/user/thirdparty/feixin_login.php?next=http%3A%2F%2Fxm.ganji.com%2Fwu%2F"
								title="" target="_blank">飞信</a>
						</p>

						<p class="gzweibo">
							关注二手网微博：
							<a class="weibo-icon" href="http://weibo.com/ganjiwang">新浪微博</a>
							<span class="line">|</span>
							<a class="tx-icon" href="http://t.qq.com/ganjiwang01">腾讯微博</a>
						</p>
					</div>
					<!--login-box end-->
				</div>
			</div>

			<script type="text/javascript">
 GJ.use(['jquery', 'js/util/event/event.js', 'js/util/validator/validator-2.js', 'passport'], function(){
         GJ.validator.addFormCallback('registerform', function(){
                  var username    = $('#registerform').find('input[name=username]').val();
                  var password    = $('#registerform').find('input[name=password]').val();
                  var password2   = $('#registerform').find('input[name=password2]').val();
                  var affirm      = $('#registerform').find('input[name=affirm]').val();
                  var checkcode   = $('#registerform').find('input[name=checkcode]').val() || null;
                  GJ.passport.login({
                            'url'       : '/user/register.php',
                            'username'  : username,
                            'password'  : password,
                            'expireDays': 0,
                            'loginData' : {
                                'next'      : "",
                                'password2' : password2,
                                'affirm'    : affirm,
                                'checkcode' : checkcode
                            },
                            'onLoginStart'  : function() {
                                $('#reg-submit').hide();
                                $('#reg-msg').show();
                            },
                            'onLoginSuccess': function(ret) {
                                next_url    = ret.next_url;
                            },
                            'onLoginError'  : function(ret) {
                                $('#reg-msg').hide();
                                $('#reg-submit').show();
                                if (ret.error_msg) {
                                    $('#reg-error').html('<span class="validatorMsg validatorError">' + ret.error_msg + '</span>');
                                }
                            },
                            'onFinish'  : function() {
                                window.location = next_url;
                            }
                        });
                        return false;
                    });
         GJ.validator("username")
            .setTipSpanId("tip_username")
           // .setEmptyValue(" ")
            .setFocusMsg("4-20个字符、汉字、字母、数字、下划线")
            .setRequired("请填写用户名")
            .setStrlenType("byte")
            .setLength(4, 20, "4-20个字符（汉字、字母、数字、下划线）")
            .setCallback(function(str){ return /^[\w|\u4E00-\u9FA5]*$/.test(str); }, "用户名仅可使用汉字、字母、数字或下划线")
            .setCallback(function(str){ return ! /^\d{11}$/.test(str); }, "手机号码不能作为用户名，请更换")
            .setAjax("/user/ajax/checkUserName.php", "此用户名已被注册");

            GJ.validator("password")
            .setTipSpanId("tip_password")
            .setFocusMsg("6-16个字符，必须为数字和字母的组合")
            .setRequired("请填写密码")
            .setStrlenType("symbol")
            .setLength(6, 16, "6-16个字符")
            .setCallback(function is_complex_password(str) { var n = str.length; if ( n < 6 ) { return false; } var cc = 0, c_step = 0; for (var i=0; i<n; ++i) { if ( str.charCodeAt(i) == str.charCodeAt(0) ) { ++ cc; } if ( i > 0 && str.charCodeAt(i) == str.charCodeAt(i-1)+1) { ++ c_step; } } if ( cc == n || c_step == n-1) { return false; } return true; }, "为保证安全，密码不能使用连续、重复的字母、数字")
            .setCallback(function is_num_str(str) { var reg=/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i; return reg.test(str);}, " 密码必须是字母和数字的组合")
            .setCompareField("!=", "username", "密码不能和用户名相同");

             GJ.validator("password2")
             .setTipSpanId("tip_password2")
             .setFocusMsg("重复输入一次密码")
             .setRequired("重复输入一次密码")
             .setCompareField("==", "password", "两次输入密码不同");

              GJ.validator("affirm")
              .setTipSpanId("tip_affirm")
              .setRequired("必须先接受赶集的条款");

               var num = "1";
               var codecheck = "1";

              if ( parseInt(num) > 10 || codecheck ) {
                  GJ.validator("checkcode")
                  .setTipSpanId("tip_checkcode")
                  .setRequired("请填写验证码")
                  .setCallback(function(str){ return str.length==4; }, "验证码不正确")
                  .setAjax("/ajax/check_code_v5.php", "验证码不正确");
              }

         GJ.validator.addFormCallback('loginform', function(){
                var username    = $('#loginform').find('input[name=login_username]').val();
                var password    = $('#loginform').find('input[name=login_password]').val();
                var checkCode   = $('#loginform').find('input[name=login_checkcode]').val();
                var next_url    = '';


                GJ.passport.login({
                    'url'       : '<%=basePath%>loggingin',
                    'username'  : username,
                    'password'  : password,
                    'checkCode' : checkCode,
                    'expireDays': $('#loginform').find('input[name=setcookie]').attr("checked") ? $('#loginform').find('input[name=setcookie]').val() : 0,
                    'loginData' : {
                        'setcookie' :  $('#loginform').find('input[name=setcookie]').attr("checked") ? $('#loginform').find('input[name=setcookie]').val() : 0,
                        'next'      : "<%=basePath%>index"
                    },
                    'onLoginStart'  : function() {
                        $('#login-submit').hide();
                        $('#login-msg').show();
                    },
                    'onLoginSuccess': function(ret) {
                        next_url    = ret.next_url;
                        GJ.setCookie('login_num', 0);
                    },
                    'onLoginError'  : function(ret) {
                        $('#login_msg_error > span').html(ret.error_msg);
                        $('#login_msg_rror').show();
                        if (ret.type == '_anonymous_') {
                            window.location.href="http://www.ganji.com/vip/anonymous.php";
                        }
                        $('#login-msg').hide();
                        $('#login-submit').show();
                    },
                    'onFinish'  : function() {
                        $("input[name='login_checkcode']").val('');
                        window.location = next_url;
                    }
                });
                return false;
            });
            GJ.validator("login_username")
            .setTipSpanId("login_tip_error")
            .setEmptyValue("用户名/邮箱/手机号")
            .setRequired("此处不能为空");

            GJ.validator("login_password")
            .setTipSpanId("login_tip_password")
            .setEmptyValue("请输入密码")
           .setRequired("密码不能为空");

        

    });
</script>

			<!--主区域结束-->
			<!-- footer s -->
			<ul id="footer" class="clearfix">
				<li>
					<a href="http://www.ganji.com/misc/abouts/index.php?act=about"
						rel="nofollow" target="_blank">关于我们</a> -
					<a href="http://www.ganji.com/tuiguang/index/" rel="nofollow"
						target="_blank">网站推广</a> -
					<a href="http://tuiguang.ganji.com/zhaoshang/agent.htm"
						rel="nofollow" target="_blank"> 渠道合作 </a> -
					<a href="http://help.ganji.com/" rel="nofollow" target="_blank">帮助中心</a>
					-
					<a style="color: #C00;" href="http://help.ganji.com/html/sjbmy/"
						rel="nofollow" target="_blank">手机号被冒用</a> -
					<a href="http://www.ganji.com/misc/abouts/link.php?act=link"
						rel="nofollow" target="_blank">友情链接</a> -
					<a target="_blank" rel="nofollow"
						href="http://www.ganji.com/misc/abouts/index.php?act=job">招贤纳士</a>
					-
					<a target="_blank" href="/quxiandaohang/">区县导航</a> -
					<a target="_blank" rel="nofollow"
						href="http://mobile.ganji.com/?ca_name=mobile_other_bottom">手机访问</a>
				</li>
			</ul>
			<!-- footer e -->
			
</script>
	</body>
</html>

